package nfa;

import interfaces.Transition;

/**
 *
 * @author Ricardo Sansores Aguilar
 */
public class GeneralizedAutomataTransition implements Transition{
    
    private AutomataNode outputNode;
    private String regularExpression;

    public GeneralizedAutomataTransition(AutomataNode outputNode, String regularExpression) {
        this.outputNode = outputNode;
        this.regularExpression = regularExpression;
    }

    /**
     * @return the outputNode
     */
    public AutomataNode getOutputNode() {
        return outputNode;
    }

    /**
     * @param outputNode the outputNode to set
     */
    public void setOutputNode(AutomataNode outputNode) {
        this.outputNode = outputNode;
    }

    /**
     * @return the regularExpression
     */
    public String getRegularExpression() {
        return regularExpression;
    }

    /**
     * @param regularExpression the regularExpression to set
     */
    public void setRegularExpression(String regularExpression) {
        this.regularExpression = regularExpression;
    }

    public String getToNodeName() {
        return outputNode.getName();
    }

    public String getTransitionLabel() {
        return regularExpression;
    }
    
    public void setToNodeName(String toNodeName) {
        this.outputNode.setName(toNodeName);
    }

    public void setTransitionLabel(String transitionLabel) {
        this.regularExpression = transitionLabel;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final GeneralizedAutomataTransition other = (GeneralizedAutomataTransition) obj;
        if (this.outputNode != other.outputNode && (this.outputNode == null || !this.outputNode.equals(other.outputNode))) {
            return false;
        }
        if ((this.regularExpression == null) ? (other.regularExpression != null) : !this.regularExpression.equals(other.regularExpression)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 73 * hash + (this.outputNode != null ? this.outputNode.hashCode() : 0);
        hash = 73 * hash + (this.regularExpression != null ? this.regularExpression.hashCode() : 0);
        return hash;
    }
    
    
    
}
